package com.sumainfor.pc.market.controller.directormarket;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.DmHousingInfoService;
import com.sumainfor.pc.market.service.RdHousingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 房源定价
 */
@RestController
@RequestMapping("/directormarket/DmHousingInfo")
public class DmHousingInfoController implements Serializable {
    @Autowired
    private DmHousingInfoService dmHousingInfoService;
    /**
     *查询房源定价列表 已通过
     * @param
     * @return
     */
    @GetMapping("/getDmHousingInfoList")
    public JsonResult getDmHousingInfoList(@RequestParam Map<String,Object>params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=dmHousingInfoService.getDmHousingInfoListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>>getCommunityList=dmHousingInfoService.getDmHousingInfoList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 市场部经理审核房源定价
     */
    @PostMapping("/updateDmHousingInfo")
    public JsonResult updateHousingHouInfo(@RequestBody Map<String,Object>params){
        JsonResult result=new JsonResult();
        int resultsjk=dmHousingInfoService.updateDmHousingInfo(params);
        if (resultsjk>0){
            result.putSuccess("审核成功");
        }else{
            result.putFailed("服务器繁忙");
        }
        return  result;
    }
    /**
     *查询房源定价列表 待审核
     * @param
     * @return
     */
    @GetMapping("/getDmHousingInfoListw")
    public JsonResult getDmHousingInfoListw(@RequestParam Map<String,Object>params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=dmHousingInfoService.getDmHousingInfoListwCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>>getCommunityList=dmHousingInfoService.getDmHousingInfoListw(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     *查询定价详情房间配置列表
     * @param
     * @return
     */
    @GetMapping("/getDmHousingInfoListByHouId")
    public JsonResult getDmHousingInfoListByHouId(@RequestParam Map<String,Object>params){
        return dmHousingInfoService.getDmHousingInfoListByHouId(params);
    }
}
